home *** CD-ROM | disk | FTP | other *** search
- #ifndef __TDriver__
- #define __TDriver__
-
- #include "TMessage.h"
- #include "IACHeaders.h"
-
- // Because these equates aren't in SysEqu.h
- const short kRdCmd = 2;
- const short kWrCmd = 3;
-
- const short kMaxApps = 16;
- const short kMaxMessages = 16;
-
- class TDriver: public HandleObject {
- public:
- // Constructor and destructor.
- TDriver();
- ~TDriver();
-
- /* Generic driver routines. These are the only public interfaces we
- * show to the world. */
- OSErr iacOpen(ParmBlkPtr oParmBlock);
- OSErr iacPrime(ParmBlkPtr pParmBlock);
- OSErr iacControl(ParmBlkPtr cntlParmBlock);
- OSErr iacStatus(ParmBlkPtr sParmBlock);
- OSErr iacClose(ParmBlkPtr cParmBlock);
-
- private:
- // Control Routines.
- /* RegisterApp takes the string in iacRecord.appName and finds a slot in the
- * array for the name (hence it "registers" the application).
- * SendMessage sends a message from one application to another (as specified
- * specified by the iacRecord fields.
- * ReceiveMessage puts the message string into the iacRecord.msgString field
- * if there's a message for the requesting application.
- * UnregisterApp removes the application's name from the array (hence the
- * application is "unregistered"). */
- short RegisterApp(IACRecord *anIACPtr);
- short SendMessage(IACRecord *anIACPtr);
- short ReceiveMessage(IACRecord *anIACPtr);
- short UnregisterApp(IACRecord *anIACPtr);
-
- // Status Routines
- /* WhosThere returns the signature of other applications which
- * have registered.
- * AnyMessagesForMe returns the number of messages waiting for the
- * reqeusting application in iacRecord.actualCount */
- void WhosThere(IACRecord *anIACPtr);
- Boolean AnyMessagesForMe(IACRecord *anIACPtr);
-
- // Message array handling routines.
- /* GetMessage gets the TMessPtr in fMessageArray[signature]
- * SetMessage sets the pointer in fMessageArray[signature] to aMsgPtr */
- TMessPtr GetMessage(short signature);
- void SetMessage(short index, TMessPtr aMsgPtr);
-
- // AppName array handling routines.
- /* GetAppName gets the application name in fAppNameArray[signature]
- * SetAppName sets the application in fAppNameArray[signature]
- * to anAppName */
- char *GetAppName(short signature);
- void SetAppName(short signature, char *anAppName);
-
- /* We'll keep an array of applications which can register with the
- * driver. I've arbitrarily set this at 16. We also keep an array
- * of TMessage pointers to passed around. This is also arbitrarily
- * set at 16. In the future, I'd probably implement this as a list of
- * messages. */
- char fAppNameArray[kMaxApps] [255];
- TMessPtr fMessageArray[kMaxMessages];
- };
-
-
- typedef TDriver *TDrvrPtr;
- #endif